package com.mb.ext.core.service.impl;


import com.mb.ext.core.dao.product.ProductCateDAO;
import com.mb.ext.core.entity.product.ProductCateEntity;
import com.mb.ext.core.service.ProductCateService;

import com.mb.ext.core.service.spec.product.ProductCateDTO;
import com.mb.ext.core.service.spec.product.ProductDTO;
import com.mb.framework.exception.DAOException;
import com.mb.framework.service.AbstractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description
 * @Author 孙浩
 * @Version V1.0.0
 * @Date 2021/7/2 0002
 */
@Service
@Qualifier("ProductCateService")
public class ProductCateServiceImpl  extends AbstractService implements ProductCateService<ProductCateDTO> {
  @Autowired
  @Qualifier("productCateDAO")
  private ProductCateDAO productCateDAO;


  @Override
  public List<ProductCateDTO> typeList() throws DAOException {
    List<ProductCateEntity> rootProductCate = productCateDAO.getHomeProductCate();
    return  rootProductCate.stream().map(x->{
      ProductCateDTO productCateDTO = new ProductCateDTO();
      productCateDTO.setSortNumber(x.getSortNumber());
      productCateDTO.setCateName(x.getCateName());
      productCateDTO.setProductCateUuid(x.getProductCateUuid());
      productCateDTO.setCatePicUrl(x.getCatePicUrl());
      return productCateDTO;
    }).collect(Collectors.toList());
  }

//  @Override
//  public List<ProductDTO> selectProductByType(String typeId) {
//
//
//
//    return null;
//  }


}
